﻿using System.Linq;
using MartinRL.ProjectEuler.Sequences;

namespace MartinRL.ProjectEuler
{
    public static class Problem025
    {
        public static ushort FindTheFirstFibonacciTermThatContains3Digits()
        {
            return FindTheFirstFibonacciTermThatContainsDigits(3);
        }

        private static ushort FindTheFirstFibonacciTermThatContainsDigits(ushort digits)
        {
            return (ushort) new FibonacciTermDigitsSequence()
                                .Select((d, i) => new {Digits = d, Index = i})
                                .First(di => di.Digits >= digits)
                                .Index;
        }

        public static int FindTheFirstFibonacciTermThatContains1000Digits()
        {
            return FindTheFirstFibonacciTermThatContainsDigits(1000);
        }
    }
}